package com.example.kafka.controller;

import com.example.kafka.service.KafkaSyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Kafka同步消息发送Controller
 */
@RestController
@RequestMapping("/kafka/sync")
public class KafkaSyncController {

    @Autowired
    private KafkaSyncService kafkaSyncService;

    /**
     * 用例1：标准同步发送
     */
    @GetMapping("/standard")
    public String sendStandard() throws Exception {
        return kafkaSyncService.sendSyncStandard();
    }

    /**
     * 用例2：同步发送+重试
     */
    @GetMapping("/retry")
    public String sendWithRetry() throws Exception {
        return kafkaSyncService.sendSyncWithRetry();
    }

    /**
     * 用例3：同步发送+超时降级
     */
    @GetMapping("/timeout-fallback")
    public String sendWithTimeoutFallback() {
        return kafkaSyncService.sendSyncWithTimeoutFallback();
    }

    /**
     * 用例4：同步发送+补偿
     */
    @GetMapping("/compensation")
    public String sendWithCompensation() {
        return kafkaSyncService.sendSyncWithCompensation();
    }

    /**
     * 用例5：同步发送+异常类型细分
     */
    @GetMapping("/error-type")
    public String sendWithErrorType() {
        return kafkaSyncService.sendSyncWithErrorType();
    }
}